package com.carkeeper.utile;

import com.carkeeper.entity.Result;
import com.carkeeper.entity.StatusCode;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

public class Upload {
    public static Result upload(MultipartFile imgFile){
        String originalFilename = imgFile.getOriginalFilename();
        try {
            byte[] bytes = imgFile.getBytes();
            QiniuUtils.upload2Qiniu(bytes,originalFilename);
            return  new Result(true, StatusCode.OK,"",originalFilename);
        } catch (IOException e) {
            e.printStackTrace();
            return  new Result(false, StatusCode.ERROR,"上传失败");
        }
    }
}
